package com.venue.hjt.venueclass.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.venue.hjt.venueclass.R;
import com.venue.hjt.venueclass.bean.StudentNews;

import java.util.List;

/**
 * 
 */

public class ParentNewsAdapter extends BaseAdapter {
    private Context mContext;
    private List<StudentNews.Data> list;
    public ParentNewsAdapter(Context mContext, List<StudentNews.Data> list) {
        this.mContext = mContext;
        this.list = list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHander viewHander;
        if (convertView==null){
            viewHander=new ViewHander();
            convertView=View.inflate(mContext, R.layout.parent_item,null);
            viewHander.tv_newsTime=convertView.findViewById(R.id.tv_newsTime);
            viewHander.tv_newsContent=convertView.findViewById(R.id.tv_newsContent);
            convertView.setTag(viewHander);
        }else{
            viewHander= (ViewHander) convertView.getTag();
        }
        StudentNews.Data data = list.get(position);
        viewHander.tv_newsContent.setText(data.message);
        viewHander.tv_newsTime.setText(data.add_time);
        return convertView;
    }
    class ViewHander{
        private TextView tv_newsTime;
        private TextView tv_newsContent;
    }
}